<template>
  <div style="width: 100%; height: 100%; padding: 0">
    <div class="page-content" v-if="!showDetail && !showPatientInfo">
      <a-card style="width: 100%; height: 100%">
        <div class="header">
          <Condition
            :condition="condition"
            :btns="['search', 'reset']"
            @search="searchHandle"
            @reset="reset"
          >
            <!-- <a-form-item>
              <a-button type="primary" v-if="raidoValue == 'todo'" @click="batchDispatch"
                >批量派单</a-button
              >
              <a-button type="primary" v-else @click="batchTransfer">批量转单</a-button>
            </a-form-item> -->
          </Condition>
          <div style="display: flex; align-items: center; justify-content: space-between">
            <a-radio-group
              button-style="solid"
              v-model:value="raidoValue"
              @change="radioValueChange"
            >
              <a-radio-button value="todo">
                待派单({{ dispatchAllCounts ? dispatchAllCounts.noSend : 0 }})
              </a-radio-button>
              <a-radio-button value="done">
                已派单({{ dispatchAllCounts ? dispatchAllCounts.send : 0 }})
              </a-radio-button>
            </a-radio-group>
            <div>
              <a-button type="primary" v-if="raidoValue == 'todo'" @click="batchDispatch"
                >批量派单</a-button
              >
              <!-- <a-button type="primary" v-else @click="batchTransfer">批量转单</a-button> -->
            </div>
          </div>
          <!-- <span> 共筛选出 {{ pagination.total }} 条数据 </span> -->
        </div>
        <div class="main">
          <a-table
            class="table"
            size="small"
            :loading="loading"
            :dataSource="List"
            :columns="columns"
            :pagination="pagination"
            @change="paginationChange"
            :sticky="{ offsetHeader: 0 }"
            :rowKey="'empi'"
            :row-selection="{ selectedRowKeys: state.selectedRowKeys, onChange: onSelectChange }"
          >
            <template #bodyCell="{ column, record, index }">
              <template v-if="column.dataIndex == 'no'">
                {{ (pagination.current - 1) * pagination.pageSize + index + 1 }}
              </template>
              <template v-else-if="column.dataIndex === 'patName'">
                <span class="patName" @click="toDetail(record)" type="link">
                  {{ record.patName }} {{ record.gender }} {{ record.age }}
                </span>
                <!-- <a-button @click="toDetail(record)" type="link">{{ record.patName }}</a-button> -->
              </template>
              <template v-else-if="column.dataIndex === 'managerName'">
                <a-button type="link" :disabled="!record.questionState" @click="followInfo(record)">
                  减重问卷
                </a-button>
              </template>
              <template v-else-if="column.dataIndex === 'memberState'">
                <a-tag
                  v-if="record.memberState == '生效中'"
                  style="color: #00b42a; background-color: #e8f7ff; border: 1px solid #00b42a"
                >
                  生效中
                </a-tag>
                <a-tag
                  v-if="record.memberState == '已中止'"
                  style="color: #1d2129; background-color: #f2f3f5; border: 1px solid #1d2129"
                >
                  已中止
                </a-tag>
                <a-tag
                  v-if="record.memberState == '已过期'"
                  style="color: #1d2129; background-color: #f2f3f5; border: 1px solid #1d2129"
                >
                  已过期
                </a-tag>
              </template>
              <template v-else-if="column.dataIndex == 'buyTime'">
                <span v-if="record.buyTime">{{
                  dayjs(record.buyTime).format('YYYY-MM-DD HH:mm')
                }}</span>
                ~
                <span v-if="record.expiredTime">{{
                  dayjs(record.expiredTime).format('YYYY-MM-DD HH:mm')
                }}</span>
              </template>
              <template v-else-if="column.dataIndex === 'vipStartTime'">
                <span v-if="record.vipStartTime">{{
                  dayjs(record.vipStartTime).format('YYYY-MM-DD HH:mm')
                }}</span>
                ~
                <span v-if="record.expiredTime">{{
                  dayjs(record.expiredTime).format('YYYY-MM-DD HH:mm')
                }}</span>
              </template>
              <template v-else-if="column.dataIndex === 'questionState'">
                <span style="color: #00b42a" v-if="record.questionState">
                  <CheckCircleFilled two-tone-color="#00B42A" />
                  已填写
                </span>
                <span style="color: #f53f3f" v-if="!record.questionState">
                  <ExclamationCircleFilled two-tone-color="#F53F3F" />
                  未填写
                </span>
              </template>
              <template v-else-if="column.dataIndex === 'pathName'">
                <span v-if="record.pathName && raidoValue == 'todo'">{{ record.pathName }}</span>
                <span
                  style="color: #1677ff; cursor: pointer"
                  v-else-if="record.pathName && raidoValue == 'done'"
                  @click="addOrUpdateHandle(record)"
                  type="link"
                >
                  {{ record.pathName }}
                </span>
                <span v-else>/</span>
              </template>
              <template v-else-if="column.dataIndex === 'serviceState'">
                <span style="color: #ff7d00" v-if="record.serviceState == 'TODO'">
                  <ExclamationCircleFilled two-tone-color="#FF7D00" />
                  待执行
                </span>
                <span style="color: #3491fa" v-if="record.serviceState == 'DOING'">
                  <ExclamationCircleFilled two-tone-color="#3491FA" />
                  处理中
                </span>
                <span style="color: #3491fa" v-if="record.serviceState == 'REPROCESSING'">
                  <ExclamationCircleFilled two-tone-color="#3491FA" />
                  处理中
                </span>
                <span style="color: #0fc6c2" v-if="record.serviceState == 'DONE'">
                  <CheckCircleFilled two-tone-color="#0FC6C2" />
                  已推送
                </span>
                <span style="color: #1d2129" v-else-if="record.serviceState == 'EXPIRED'">
                  <CloseCircleOutlined two-tone-color="#1d2129" />
                  已过期
                </span>
              </template>
              <template v-else-if="column.dataIndex === 'groupName'">
                <span v-if="record.groupName">{{ record.groupName }}</span>
                <span v-else>/</span>
              </template>
              <template v-else-if="column.dataIndex === 'leaderName'">
                <span v-if="record.leaderName">{{ record.leaderName }}</span>
                <span v-else>/</span>
              </template>

              <template v-else-if="column.dataIndex === 'action'">
                <a-button
                  type="link"
                  @click="dispatchHandle(record)"
                  :disabled="record.memberState != '生效中'"
                  >{{ raidoValue == 'todo' ? '派单' : '转单' }}</a-button
                >
              </template>
            </template>
          </a-table>
        </div>
      </a-card>

      <a-modal v-model:open="dispatchOpen" :title="dispatchTitle" :mask-closable="false">
        <a-form ref="dispatchFormRef" :model="dispatchForm">
          <a-form-item
            label="选择服务团队"
            name="dispatchUserId"
            :rules="[{ required: true, message: '请选择服务团队' }]"
          >
            <a-select
              v-model:value="dispatchForm.dispatchUserId"
              style="width: 100%"
              placeholder="选择服务团队"
              showSearch
              :options="managerDataTwo"
            >
              <!-- @search="customSearch" -->
              <!-- <a-select-option v-for="item in managerDataTwo" :key="item.value">
                {{ item.label }} &nbsp; {{ item.leaderName }}组长
                {{ item.label }}
              </a-select-option> -->
            </a-select>
          </a-form-item>
        </a-form>
        <template #footer>
          <a-button key="back" @click="dispatchOpen = false">取消</a-button>
          <a-button key="submit" type="primary" @click="saveHandle" :loading="dispatchLoading">
            确定
          </a-button>
        </template>
      </a-modal>

      <!-- <t-form
            style="display: block; width: 100%; height: 100%"
            :formData="formData.content"
            :disabled="true"
          ></t-form> -->
      <FollowInfo ref="followInfoRef" />
    </div>
    <ManaPlan ref="manaPlanRef" v-if="showDetail" @close="goBack" />
    <PatientInfo ref="patientInfoRef" v-if="showPatientInfo" @close="gopatientBack" />
  </div>
</template>
<script lang="ts" setup>
import Condition from '@/components/ConditionSearch/index.vue'
import { CheckCircleFilled, ExclamationCircleFilled } from '@ant-design/icons-vue'
import { ref, onMounted, reactive } from 'vue'
import dayjs from 'dayjs'
import FollowInfo from './followInfo.vue'
import { message } from 'ant-design-vue'
import {
  getDispatchList,
  getManagePlanByDiseaseType,
  getManagerLeader,
  getMemberGroup,
  batchDispatchApiNew,
  getAllUserGroup,
  questionAnswer
} from '@/api/healthManaWorkbench/index'
import { useRoute } from 'vue-router'

const route = useRoute()

import ManaPlan from '@/views/healthManaWorkbench/implement/manaPlan.vue'
import PatientInfo from '@/views/examinatePatients/patientInfo.vue'
const formData = ref({})
const showDetail = ref(false)
const showPatientInfo = ref(false)
const loading = ref<boolean>(false)
const List = ref<any[]>([])
const raidoValue = ref('todo')
const state = reactive<{
  selectedRowKeys: Key[]
}>({
  selectedRowKeys: []
})

const groupFormData: any = ref([])
const managerDataTwo: any = ref([])
const managerFormData: any = ref([])

const dispatchAllCounts = ref()
const dispatchOpen = ref(false)
// const dispatchOpenTwo = ref(false)
const dispatchOpenTwo = ref(true)

const dispatchTitle = ref('')

const manaPathData = ref([])
const dispatchForm = reactive({
  dispatchUserId: undefined
})

const conditionTodo = ref([
  {
    title: '服务包购买时间',
    dataIndex: 'buyTime',
    type: 'dayRange',
    value: [],
    format: 'YYYY-MM-DD HH:mm',
    showTime: true,
    style: { width: '300px' }
  },
  {
    title: '',
    dataIndex: 'condition',
    type: 'input',
    value: '',
    placeholder: '请输入姓名/证件号'
  },
  {
    title: '管理路径',
    dataIndex: 'pathId',
    type: 'select',
    data: manaPathData.value,
    value: undefined,
    placeholder: '请选择管理路径',
    showSearch: true
  },
  {
    title: '会员状态',
    dataIndex: 'memberState',
    type: 'select',
    value: undefined,
    placeholder: '请选择会员状态',
    data: [
      {
        label: '生效中',
        value: 1
      },
      {
        label: '已过期',
        value: 8
      }
    ]
  }
])
const conditionDone = ref([
  {
    title: '服务包购买时间',
    dataIndex: 'buyTime',
    type: 'dayRange',
    value: [],
    format: 'YYYY-MM-DD HH:mm',
    showTime: true,
    style: { width: '300px' }
  },
  //   {
  //     title: '报告生成时间',
  //     dataIndex: 'visitTime',
  //     type: 'dayRange',
  //     value: [],
  //     format: 'YYYY-MM-DD HH:mm',
  //     showTime: true,
  //     style: { width: '300px' }
  //   },
  {
    title: '',
    dataIndex: 'condition',
    type: 'input',
    value: '',
    placeholder: '请输入姓名/证件号'
  },
  {
    title: '',
    dataIndex: 'manager',
    type: 'select',
    value: undefined,
    data: managerFormData.value,
    showSearch: true,
    placeholder: '请选择组长'
  },
  {
    title: '',
    dataIndex: 'groupId',
    type: 'select',
    value: undefined,
    data: groupFormData.value,
    showSearch: true,
    placeholder: '请选择组'
  },
  {
    title: '管理路径',
    dataIndex: 'pathId',
    type: 'select',
    data: manaPathData.value,
    value: undefined,
    placeholder: '请选择管理路径',
    showSearch: true
  },
  //   {
  //     title: '问卷状态',
  //     dataIndex: 'questionState',
  //     type: 'select',
  //     data: [
  //       {
  //         label: '未填写',
  //         value: false
  //       },
  //       {
  //         label: '已填写',
  //         value: true
  //       }
  //     ],
  //     value: undefined,
  //     placeholder: '请选择问卷状态'
  //   },
  {
    title: '服务状态',
    dataIndex: 'serviceState',
    type: 'select',
    value: undefined,
    data: [
      {
        label: '待执行',
        value: 'TODO'
      },
      {
        label: '处理中',
        value: 'DOING'
      },
      {
        label: '已推送',
        value: 'DONE'
      }
    ],
    placeholder: '请选择服务状态'
  },
  {
    title: '会员状态',
    dataIndex: 'memberState',
    type: 'select',
    value: undefined,
    placeholder: '请选择会员状态',
    data: [
      {
        label: '生效中',
        value: 1
      },
      {
        label: '已过期',
        value: 8
      }
    ]
  }
])

const condition = ref()
const columns = ref<any[]>([])
const columnsTodo = ref<any[]>([
  {
    title: '序号',
    dataIndex: 'no',
    key: 'no',
    align: 'left',
    width: 80
  },
  {
    title: '账号',
    dataIndex: 'userPhone',
    key: 'userPhone',
    align: 'left'
  },
  {
    title: '就诊人手机号',
    dataIndex: 'phone',
    key: 'phone',
    align: 'left'
  },
  {
    title: '就诊人',
    dataIndex: 'patName',
    key: 'patName',
    align: 'left'
  },
  //   {
  //     title: '性别',
  //     dataIndex: 'gender',
  //     key: 'gender',
  //     align: 'left'
  //   },
  //   {
  //     title: '年龄',
  //     dataIndex: 'age',
  //     key: 'age',
  //     align: 'left'
  //   },
  {
    title: '证件号',
    dataIndex: 'idNo',
    key: 'idNo',
    align: 'left',
    width: 150
  },
  {
    title: '会员状态',
    dataIndex: 'memberState',
    key: 'memberState',
    align: 'left'
  },
  {
    title: '服务包有效期',
    dataIndex: 'buyTime',
    key: 'buyTime',
    align: 'left'
  },
  {
    title: '服务包名称',
    dataIndex: 'tradeName',
    key: 'tradeName',
    align: 'left'
  },
  //   {
  //     title: '报告生成时间',
  //     dataIndex: 'visitTime',
  //     key: 'visitTime',
  //     align: 'left'
  //   },

  {
    title: '管理路径',
    dataIndex: 'pathName',
    key: 'pathName',
    align: 'left'
  },
  {
    title: '问卷',
    dataIndex: 'managerName',
    key: 'managerName',
    align: 'left',
    width: 100
  },
  // {
  //   title: '服务状态',
  //   dataIndex: 'state',
  //   key: 'state',
  //   align: 'left'
  // },
  {
    title: '操作',
    dataIndex: 'action',
    key: 'action',
    align: 'left',
    width: 80
  }
])

const columnsDone = ref<any[]>([
  {
    title: '序号',
    dataIndex: 'no',
    key: 'no',
    align: 'left',
    width: 80
  },
  {
    title: '账号',
    dataIndex: 'userPhone',
    key: 'userPhone',
    align: 'left'
  },
  {
    title: '就诊人手机号',
    dataIndex: 'phone',
    key: 'phone',
    align: 'left'
  },
  {
    title: '就诊人',
    dataIndex: 'patName',
    key: 'patName',
    align: 'left'
  },
  //   {
  //     title: '性别',
  //     dataIndex: 'gender',
  //     key: 'gender',
  //     align: 'left'
  //   },
  //   {
  //     title: '年龄',
  //     dataIndex: 'age',
  //     key: 'age',
  //     align: 'left'
  //   },
  {
    title: '证件号',
    dataIndex: 'idNo',
    key: 'idNo',
    align: 'left',
    width: 150
  },
  {
    title: '会员状态',
    dataIndex: 'memberState',
    key: 'memberState',
    align: 'left'
  },
  {
    title: '服务包有效期',
    dataIndex: 'buyTime',
    key: 'buyTime',
    align: 'left',
    width: 150
  },
  {
    title: '服务包名称',
    dataIndex: 'tradeName',
    key: 'tradeName',
    align: 'left'
  },
  //   {
  //     title: '报告生成时间',
  //     dataIndex: 'visitTime',
  //     key: 'visitTime',
  //     align: 'left'
  //   },

  {
    title: '管理路径',
    dataIndex: 'pathName',
    key: 'pathName',
    align: 'left'
  },
  {
    title: '问卷',
    dataIndex: 'managerName',
    key: 'managerName',
    align: 'left',
    width: 100
  }
  //   {
  //     title: '服务状态',
  //     dataIndex: 'serviceState',
  //     key: 'serviceState',
  //     align: 'left'
  //   },
  //   {
  //     title: '负责人',
  //     dataIndex: 'managerName',
  //     key: 'managerName',
  //     align: 'left'
  //   },
  //   {
  //     title: '操作',
  //     dataIndex: 'action',
  //     key: 'action',
  //     align: 'left',
  //     width: 100
  //   }
])

const pagination = ref<any>({
  current: 1,
  total: 0,
  pageSize: 10,
  showSizeChanger: true,
  pageSizeOptions: ['10', '20', '50', '100'],
  showQuickJumper: true
})
const paginationChange = (page: any) => {
  pagination.value = { ...page }
  loading.value = true
  getDataList()
}

const onSelectChange = (selectedRowKeys: Key[]) => {
  state.selectedRowKeys = selectedRowKeys
}

const manaPlanRef = ref()
const addOrUpdateHandle = (data) => {
  showDetail.value = true
  nextTick(() => {
    manaPlanRef.value.init(data, 'weightLose')
  })
}

const getDataList = () => {
  state.selectedRowKeys = []
  List.value = []
  const obj = condition.value.reduce((c, v) => {
    if (v.value || v.value === 0 || v.value === false) {
      if (v.dataIndex == 'visitTime') {
        return Object.assign(c, {
          visitTimeSta: v.value.length ? dayjs(v.value[0]).format('YYYY-MM-DD HH:mm:00') : '',
          visitTimeEnd: v.value.length ? dayjs(v.value[1]).format('YYYY-MM-DD HH:mm:00') : ''
        })
      } else if (v.dataIndex == 'buyTime') {
        return Object.assign(c, {
          buyTimeSta: v.value.length ? dayjs(v.value[0]).format('YYYY-MM-DD HH:mm:00') : '',
          buyTimeEnd: v.value.length ? dayjs(v.value[1]).format('YYYY-MM-DD HH:mm:00') : ''
        })
      } else {
        return Object.assign(c, { [v.dataIndex]: v.value })
      }
    } else {
      return c
    }
  }, {})
  getDispatchList({
    ...obj,
    serviceState: obj.serviceState ? [obj.serviceState] : [],
    page: pagination.value.current,
    limit: pagination.value.pageSize,
    isSet: raidoValue.value == 'todo' ? false : true,
    diseaseType: 'weightLose',
    chose: true
  })
    .then((res) => {
      dispatchAllCounts.value = res.data
      List.value = res.data.page.list
      pagination.value.total = res.data.page.total
      loading.value = false

      List.value = [...List.value]
    })
    .catch(() => {
      loading.value = false
    })
}
onMounted(async () => {
  if (route.query && route.query.type === 'manaPlan') {
    showDetail.value = true
    nextTick(() => {
      manaPlanRef.value.init(
        {
          ...route.query,
          empi: route.query.empi,
          userId: route.query.id
        },
        'weightLose'
      )
    })
  }

  managerFormData.value = []
  groupFormData.value = []
  loading.value = true
  columns.value = []
  //   condition.value = []
  condition.value = conditionTodo.value
  await getManaPath()
  await getAllUserGroupFun()
  await getManagerLeader().then(async (res) => {
    res.data.forEach((item) => {
      managerFormData.value.push({
        value: item.memberId,
        label: item.memberName
      })
    })
    conditionDone.value[2].data = managerFormData.value
    conditionDone.value = [...conditionDone.value]
  })
  await getMemberGroup().then(async (res) => {
    res.data.forEach((item) => {
      groupFormData.value.push({
        value: item.groupId,
        label: item.groupName
      })
    })
    conditionDone.value[3].data = groupFormData.value
    conditionDone.value = [...conditionDone.value]
  })

  columns.value = [...columns.value, ...columnsTodo.value]
  getDataList()
})

const followInfoRef = ref()
const followInfo = (item) => {
  followInfoRef.value.init(item)

  // questionAnswer(item)
  //   .then((res) => {
  //     loading.value = false
  //     followInfoRef.value.init(res.data.questionnaireInfoVO, res.data.patientQuestionnaireAnswerVO)
  //   })
  //   .catch(() => {

  //   })
}
const getManaPath = async () => {
  await getManagePlanByDiseaseType({
    diseaseType: 'weightLose'
  }).then((res) => {
    if (res.data && res.data.length > 0) {
      res.data.map((item) => {
        item.label = item.managePathName
        item.value = item.id
      })
      manaPathData.value = res.data
    } else {
      manaPathData.value = []
    }
    conditionTodo.value[2].data = manaPathData.value
    conditionDone.value[4].data = manaPathData.value
  })
}
const getAllUserGroupFun = async () => {
  await getAllUserGroup({}).then((res) => {
    managerDataTwo.value = []
    res.data.forEach((item) => {
      if (item.groupName) {
        managerDataTwo.value.push({
          value: item.groupId,
          label: item.groupName + '  ' + item.leaderName + '组长',
          leaderName: item.leaderName
        })
      }
    })
  })
}
// 患者详情
const patientInfoRef = ref()
const toDetail = (data) => {
  showPatientInfo.value = true
  nextTick(() => {
    patientInfoRef.value.initRouterInfo(data)
  })
}

const searchHandle = () => {
  pagination.value.current = 1
  loading.value = true
  getDataList()
}
const reset = () => {
  managerFormData.value = []
  groupFormData.value = []
  pagination.value.current = 1
  pagination.value.pageSize = 10
  getManaPath()

  condition.value.map((v) => {
    if (v.type === 'select') {
      v.value = undefined
    } else if (v.type === 'dayRange') {
      v.value = []
    } else {
      v.value = ''
    }
  })
  loading.value = true
  getDataList()
}

const isDispatchData: any = ref([])

const dispatchFormRef = ref()
// 批量派单
const batchDispatch = () => {
  isDispatchData.value = []
  if (state.selectedRowKeys.length) {
    dispatchOpen.value = true
    dispatchTitle.value = '批量派单'
    dispatchForm.dispatchUserId = undefined
    isDispatchData.value = List.value.filter((item) => {
      return state.selectedRowKeys.includes(item.empi)
    })
  } else {
    message.warning('请选择需要派单的记录')
  }
}
// 批量转单
const batchTransfer = () => {
  isDispatchData.value = []
  if (state.selectedRowKeys.length) {
    dispatchOpen.value = true
    dispatchTitle.value = '批量转单'
    dispatchForm.dispatchUserId = undefined
    isDispatchData.value = List.value.filter((item) => {
      return state.selectedRowKeys.includes(item.empi)
    })
  } else {
    message.warning('请选择需要转单的记录')
  }
}

// 单条记录操作
const dispatchHandle = (data) => {
  isDispatchData.value = [data]
  dispatchOpen.value = true
  dispatchForm.dispatchUserId = undefined
  if (raidoValue.value == 'todo') {
    dispatchTitle.value = '派单'
  } else {
    dispatchTitle.value = '转单'
  }
}

const dispatchLoading = ref(false)
// 派单 转单操作
const saveHandle = () => {
  dispatchFormRef.value.validate().then(() => {
    isDispatchData.value.forEach((item) => {
      item.managerId = dispatchForm.dispatchUserId
    })
    dispatchLoading.value = true
    batchDispatchApiNew(isDispatchData.value)
      .then((res) => {
        dispatchLoading.value = false
        message.success(`${raidoValue.value === 'todo' ? '派单' : '转单'}成功`)
        dispatchOpen.value = false
        if (raidoValue.value === 'todo') {
          searchHandle()
        } else {
          loading.value = true
          getDataList()
        }
      })
      .catch(() => {
        dispatchLoading.value = false
      })
  })
}

const radioValueChange = (e) => {
  let columnCurrent: any = []
  columns.value = []
  condition.value = []
  if (e.target.value == 'done') {
    columnCurrent = [
      {
        title: '序号',
        dataIndex: 'no',
        key: 'no',
        align: 'left',
        width: 80
      },
      {
        title: '账号',
        dataIndex: 'userPhone',
        key: 'userPhone',
        align: 'left'
      },
      {
        title: '就诊人手机号',
        dataIndex: 'phone',
        key: 'phone',
        align: 'left'
      },
      {
        title: '就诊人',
        dataIndex: 'patName',
        key: 'patName',
        align: 'left'
      },
      //   {
      //     title: '性别',
      //     dataIndex: 'gender',
      //     key: 'gender',
      //     align: 'left'
      //   },
      //   {
      //     title: '年龄',
      //     dataIndex: 'age',
      //     key: 'age',
      //     align: 'left'
      //   },
      {
        title: '证件号',
        dataIndex: 'idNo',
        key: 'idNo',
        align: 'left',
        width: 150
      },
      {
        title: '会员状态',
        dataIndex: 'memberState',
        key: 'memberState',
        align: 'left'
      },
      {
        title: '服务包有效期',
        dataIndex: 'buyTime',
        key: 'buyTime',
        align: 'left',
        width: 150
      },
      {
        title: '服务包名称',
        dataIndex: 'tradeName',
        key: 'tradeName',
        align: 'left'
      },
      //   {
      //     title: '报告生成时间',
      //     dataIndex: 'visitTime',
      //     key: 'visitTime',
      //     align: 'left'
      //   },

      {
        title: '管理路径',
        dataIndex: 'pathName',
        key: 'pathName',
        align: 'left'
      },
      {
        title: '问卷',
        dataIndex: 'managerName',
        key: 'managerName',
        align: 'left',
        width: 100
      },
      {
        title: '服务状态',
        dataIndex: 'serviceState',
        key: 'serviceState',
        align: 'left'
      },
      {
        title: '服务团队',
        dataIndex: 'groupName',
        key: 'groupName',
        align: 'left'
      },
      {
        title: '组长',
        dataIndex: 'leaderName',
        key: 'leaderName',
        align: 'left'
      }
      //   {
      //     title: '操作',
      //     dataIndex: 'action',
      //     key: 'action',
      //     align: 'left',
      //     width: 100
      //   }
    ]
    condition.value = [...condition.value, ...conditionDone.value]
  } else {
    columnCurrent = [
      {
        title: '序号',
        dataIndex: 'no',
        key: 'no',
        align: 'left',
        width: 80
      },
      {
        title: '账号',
        dataIndex: 'userPhone',
        key: 'userPhone',
        align: 'left'
      },
      {
        title: '就诊人手机号',
        dataIndex: 'phone',
        key: 'phone',
        align: 'left'
      },
      {
        title: '就诊人',
        dataIndex: 'patName',
        key: 'patName',
        align: 'left'
      },
      //   {
      //     title: '性别',
      //     dataIndex: 'gender',
      //     key: 'gender',
      //     align: 'left'
      //   },
      //   {
      //     title: '年龄',
      //     dataIndex: 'age',
      //     key: 'age',
      //     align: 'left'
      //   },
      {
        title: '证件号',
        dataIndex: 'idNo',
        key: 'idNo',
        align: 'left',
        width: 150
      },
      {
        title: '会员状态',
        dataIndex: 'memberState',
        key: 'memberState',
        align: 'left'
      },
      {
        title: '服务包有效期',
        dataIndex: 'buyTime',
        key: 'buyTime',
        align: 'left',
        width: 150
      },
      {
        title: '服务包名称',
        dataIndex: 'tradeName',
        key: 'tradeName',
        align: 'left'
      },
      //   {
      //     title: '报告生成时间',
      //     dataIndex: 'visitTime',
      //     key: 'visitTime',
      //     align: 'left'
      //   },

      {
        title: '管理路径',
        dataIndex: 'pathName',
        key: 'pathName',
        align: 'left'
      },
      {
        title: '问卷',
        dataIndex: 'managerName',
        key: 'managerName',
        align: 'left',
        width: 100
      },
      // {
      //   title: '服务状态',
      //   dataIndex: 'state',
      //   key: 'state',
      //   align: 'left'
      // },
      {
        title: '操作',
        dataIndex: 'action',
        key: 'action',
        align: 'left',
        width: 80
      }
    ]
    condition.value = [...condition.value, ...conditionTodo.value]
  }

  columns.value = JSON.parse(JSON.stringify(columnCurrent))

  reset()
}

const goBack = () => {
  showDetail.value = false
  loading.value = true
  getDataList()
}

const gopatientBack = () => {
  showPatientInfo.value = false
  loading.value = true
  getDataList()
}
</script>
<style lang="less" scoped>
.header {
  display: flex;
  justify-content: space-between;
}

.main {
  flex: 1 1 auto;
  margin-top: 16px;
  overflow: hidden auto;

  .patName {
    color: #1677ff;

    &:hover {
      cursor: pointer;
      opacity: 0.7;
    }
  }

  .table {
    .questionName {
      color: #1677ff;

      &:hover {
        cursor: pointer;
        opacity: 0.8;
      }
    }
  }
}

.page-content {
  padding: 16px;
}

.questionWrap {
  height: 60vh;
}
</style>
